package com.xiaoma.bingo.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.dexcoder.commons.pager.Pager;
import com.dexcoder.dal.JdbcDao;
import com.dexcoder.dal.spring.page.PageControl;
import com.xiaoma.bingo.entity.Company;

@Service
public class CompanyService{

    @Autowired
    private JdbcDao jdbcDao;
    
    public Pager findAll(int currentPage, int itemsPerPage) {
        PageControl.performPage(currentPage, itemsPerPage);
        jdbcDao.queryList(Company.class);
        return PageControl.getPager();
        
    }
    
    public void save(Company company) {
        jdbcDao.save(company);
    }
    
    public void delete(Integer id) {
        jdbcDao.delete(Company.class, id);
    }
    
    public void update(Company company) {
        jdbcDao.update(company);
    }
    
    public Company getById(Integer id) {
        return jdbcDao.get(Company.class, id);
    }
}
